<template>
  <div class="actions-bar">
    <div class="search-box">
      <input 
        type="text" 
        :value="searchQuery"
        @input="$emit('update:searchQuery', $event.target.value)"
        placeholder="搜索知识库..." 
        class="search-input"
        @keyup.enter="handleSearch"
      >
      <button class="search-btn" @click="handleSearch">🔍</button>
    </div>
    <button class="btn btn-primary" @click="handleUploadClick">
      <span>+</span> 上传文档
    </button>
  </div>
</template>

<script>
export default {
  name: 'ActionsBar',
  props: {
    searchQuery: {
      type: String,
      default: ''
    }
  },
  emits: ['search', 'uploadClick'],
  methods: {
    handleSearch() {
      this.$emit('search');
    },
    handleUploadClick() {
      this.$emit('uploadClick');
    }
  }
};
</script>

<style scoped>
.actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  gap: 20px;
}

.search-box {
  display: flex;
  flex: 1;
  max-width: 400px;
}

.search-input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #e1e5e9;
  border-radius: 8px 0 0 8px;
  font-size: 1rem;
  outline: none;
}

.search-input:focus {
  border-color: #4A90E2;
}

.search-btn {
  padding: 12px 20px;
  border: 1px solid #e1e5e9;
  border-left: none;
  border-radius: 0 8px 8px 0;
  background: #f8f9fa;
  cursor: pointer;
  transition: background 0.3s ease;
}

.search-btn:hover {
  background: #e9ecef;
}

.btn {
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: #1976d2;
  color: white;
}

.btn-primary:hover {
  background: #1565c0;
}

@media (max-width: 768px) {
  .actions-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    max-width: none;
  }
}
</style>